package com.hmy.finance.dal.po;

import com.baomidou.mybatisplus.annotation.*;
import com.hmy.finance.common.enums.PaymentStatusEnum;
import com.hmy.finance.dal.po.json.ProfitLossInfoJson;
import com.hmy.finance.dal.po.json.ProfitLossInfoJsonHandler;
import lombok.Data;
import org.apache.ibatis.type.EnumTypeHandler;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 设备日费用账单流水
 *
 * @author songkf
 * @TableName device_daily_bill
 */
@TableName(value = "device_daily_bill", autoResultMap = true)
@Data
public class DeviceDailyBillPo implements Serializable {
    private static final long serialVersionUID = -8445052656926800266L;
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    /**
     * 设备租赁记录ID
     */
    @TableField(value = "device_rental_record_id")
    private Long deviceRentalRecordId;

    /**
     * 客户ID
     */
    @TableField(value = "customer_id")
    private Long customerId;

    /**
     * 合同ID
     */
    @TableField(value = "contract_id")
    private Long contractId;

    /**
     * 合同编号
     */
    @TableField(value = "contract_no")
    private String contractNo;

    /**
     * 进场单ID
     */
    @TableField(value = "entry_form_id")
    private Long entryFormId;

    /**
     * 设备ID
     */
    @TableField(value = "device_id")
    private Long deviceId;

    /**
     * 设备编号
     */
    @TableField(value = "device_no")
    private String deviceNo;

    /**
     * 日租金费用
     */
    @TableField(value = "daily_fee")
    private BigDecimal dailyFee;

    /**
     * 月租金费用
     */
    @TableField(value = "monthly_fee")
    private BigDecimal monthlyFee;
    /**
     * 实际产生的租金
     */
    @TableField(value = "fee")
    private BigDecimal fee;
    /**
     * 计费天数
     */
    @TableField(value = "charge_days")
    private Double chargeDays;
    /**
     * 回款金额
     */
    @TableField(value = "paid_amount")
    private BigDecimal paidAmount;

    /**
     * 未回款金额
     */
    @TableField(value = "unpaid_amount")
    private BigDecimal unpaidAmount;
    /**
     * 回款标识 (1-未回款, 2-部分回款, 3-已回款)
     */
    @TableField(value = "payment_status", typeHandler = EnumTypeHandler.class)
    private PaymentStatusEnum paymentStatus;
    /**
     * 损益总金额
     */
    @TableField(value = "total_profit_loss_amount")
    private BigDecimal totalProfitLossAmount;

    /**
     * 总账单-已对账总金额
     */
    @TableField(value = "history_reconciled_amount")
    private BigDecimal historyReconciledAmount;

    /**
     * 损益详细信息
     */
    @TableField(value = "profit_loss_info", typeHandler = ProfitLossInfoJsonHandler.class)
    private List<ProfitLossInfoJson> profitLossInfo;

    /**
     * 未对账总金额
     */
    @TableField(value = "total_unreconciled_amount")
    private BigDecimal totalUnreconciledAmount;

    /**
     * 已对账总金额
     */
    @TableField(value = "total_reconciled_amount")
    private BigDecimal totalReconciledAmount;

    /**
     * 总营收
     */
    @TableField(value = "total_revenue_amount")
    private BigDecimal totalRevenueAmount;
    /**
     * 报停标识
     */
    @TableField(value = "pause_flag")
    private Boolean pauseFlag = false;
    /**
     * 关联报停损益记录ID
     */
    @TableField(value = "pause_profit_loss_record_id")
    private Long pauseProfitLossRecordId;
    /**
     * 费用状态标识
     */
    @TableField(value = "fee_status")
    private Boolean feeStatus = true;
    /**
     * 类型
     * 1-出租首日，2-报停，9-退租当日
     */
    @TableField(value = "type")
    private Integer type;
    /**
     * 费用发生日期
     */
    @TableField(value = "fee_incurred_time")
    private LocalDateTime feeIncurredTime;
    @TableLogic
    private Boolean isDeleted;
}